package xdu.lz.stage2_design_pattern.chapter3_observer_pattern.observerApp2;

public class WorkerObserver extends WeatherObserver {

	//维护者订阅的主题
	private WeatherStationSubject weatherStation;

	private final String name;

	public WorkerObserver(String name, WeatherStationSubject weatherStation) {
		//自动把自己加入订阅者的集合
		super(weatherStation);
		this.name = name;
	}

	public void notifyWeather(String weather){
		if("晴天".equals(weather)){
			System.out.println("晴天啦................工人"+name);
		}else if("雾霾".equals(weather)){
			System.out.println("雾霾啦................工人"+name);
		}else if("刮风".equals(weather)){
			System.out.println("刮风啦................工人"+name);
		}else if("冰雹".equals(weather)){
			System.out.println("冰雹啦................工人"+name);
		}else if("下雪".equals(weather)){
			System.out.println("下雪啦................工人"+name);
		}
	}
}
